package com.kiloai.digcust.mvp.view.activity;

import android.content.Intent;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.view.View;

import com.kiloai.base.basemvp.MVPBaseActivity;
import com.kiloai.base.custom.CompatTitleBar;
import com.kiloai.digcust.R;
import com.kiloai.digcust.mvp.presenter.LoginPresenter;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;

/**
 * Created by david on 2018/8/15.
 */

public class LoginActivity extends MVPBaseActivity<LoginActivity, LoginPresenter> {
    @BindView(R.id.compatTitleBar)
    CompatTitleBar compatTitleBar;
    private LoginPresenter presenter;

    @Override
    protected LoginPresenter createPresenter() {
        if (presenter == null) {
            presenter = new LoginPresenter();
        }
        return presenter;
    }

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_login);
        ButterKnife.bind(this);
        initView();
    }

    private void initView() {
        compatTitleBar.setCenterTitle(getString(R.string.login));
    }


    @OnClick({R.id.btn_code, R.id.btn_login})
    public void onViewClicked(View view) {
        switch (view.getId()) {
            case R.id.btn_code:
                presenter.getCode("digcust007", "hewei2");
                break;
            case R.id.btn_login:
                loginSuccess();
                presenter.login("digcust007", "hewei", "q1w2e3r4t5", "123431");
                break;
        }
    }

    public void setGetCodeView(String s, boolean b) {

    }

    public void loginSuccess() {
        startActivity(new Intent(this, MainActivity.class));
    }
}
